package co.edu.unal.geditor.view.tools;

import java.awt.Point;

import co.edu.unal.geditor.controller.action.tool.SquareToolAction;
import co.edu.unal.geditor.model.BoundBox;
import co.edu.unal.geditor.model.GraphElement;
import co.edu.unal.geditor.model.RectangleElement;

public class SquareCreationTool extends RectangleCreationTool
{
	// v0.6 : SquareCreationTool provides its own Factory class 
	private static class Factory extends ToolFactory
	{
		protected Tool create()
		{
			return new SquareCreationTool();
		}
	}

	// this block executed when the class object is loaded in the VM
	// registers its Factory 
	static
	{
		ToolFactory.register( SquareCreationTool.class.getName(), new Factory() );
	}

	public GraphElement createObject( Point ptPressed, Point ptReleased )
	{
		BoundBox bb = new BoundBox( ptPressed, ptReleased );
		bb.goSquare();

		return super.createObject( bb.getLeftUp(), bb.getRightDown() );
	}

	@Override
	protected void initAction()
	{
		setAction( new SquareToolAction() );
		if(feedbackGraphElemet==null)
		{
		feedbackGraphElemet = new RectangleElement(new Point(0,0), new Point(20,20));
		}

	}

}
